package company;

import java.util.ArrayList;
import java.util.List;

public class InorderTraversal {
    public static void main(String[] args) {
    }
    public static List<Integer> inorderTraversal (TreeNode2 treeNode) {
        if (treeNode == null) {
            return new ArrayList<>();
        }
        List<Integer> res = new ArrayList<>(inorderTraversal(treeNode.getLeft()));
        res.add(treeNode.val);
        res.addAll(inorderTraversal(treeNode.getRight()));
        return res;
    }
}

class TreeNode2 {
    int val;
    TreeNode2 left;
    TreeNode2 right;

    TreeNode2() {
    }

    TreeNode2(int val) {
        this.val = val;
    }

    TreeNode2(int val, TreeNode2 left, TreeNode2 right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
    public TreeNode2 getLeft() {
        return left;
    }

    public void setLeft(TreeNode2 left) {
        this.left = left;
    }

    public TreeNode2 getRight() {
        return right;
    }

    public void setRight(TreeNode2 right) {
        this.right = right;
    }

    public int getVal() {
        return this.val;
    }

    public void setVal(int val) {
        this.val = val;
    }
}
